#include <bits/stdc++.h>
#define int long long

using namespace std;

const int N = 2e5 + 5;

int T;
int n, m, cnt;
double L, V;
double a[N], v[N], p[N], d[N];
bool st[N];
struct node{
    double l, r;
    int tag; // 0->[), 1->(), -1->NULL
}c[N], b[N];

bool check_A() {
    bool f = 1;
    for (int i = 1; i <= n; i ++ ) if (a[i] != 0) f = 0;
    return f;
}

void solve_A() {
    double now = -1;
    for (int i = 1; i <= m; i ++ ) now = max(now, p[i]);
    int ans = 0;
    for (int i = 1; i <= n; i ++ )
        if (v[i] > V && d[i] <= now) ans ++ ;
    cout << ans << ' ';
    if (ans == 0) cout << m << '\n';
    else cout << m - 1 << '\n';
    return ;
}

int ask(double x, int ttt) {
    int l = 1, r = m, ans = -1, mid;
    if (ttt == 0) {
        while (l <= r) {
            int mid = (l + r) >> 1;
            if (p[mid] >= x) {
                ans = mid;
                r = mid - 1;
            } else l = mid + 1;
        }
    } else {
        while (l <= r) {
            int mid = (l + r) >> 1;
            if (p[mid] > x) {
                ans = mid;
                r = mid - 1;
            } else l = mid + 1;
        }
    }
    return ans;
}

bool cmp(node u, node v) {
    return u.l < v.l;
}

bool check_B() {
    bool f = 1;
    for (int i = 1; i <= n; i ++ ) {
        if (a[i] <= 0) f = 0;
    }
    return f;
}

void solve_B() {
    sort(p + 1, p + m + 1);
    
    for (int i = 1; i <= n; i ++ ) {
        if (a[i] == 0 && v[i] > V) c[i] = {d[i], L + 1, 0};
        if (a[i] == 0 && v[i] <= V) c[i].tag = -1;
        if (a[i] > 0 && v[i] > V) c[i] = {d[i], L + 1, 0};
        if (a[i] > 0 && v[i] <= V) {
            double ttt = (V * V - v[i] * v[i]) / (2 * a[i]);
            if (d[i] + ttt >= L) c[i].tag = -1;
            else c[i] = {d[i] + ttt, L + 1, 1};
        }
        if (a[i] < 0 && v[i] <= V) c[i].tag = -1;
        if (a[i] < 0 && v[i] > V) {
            double ttt = (V * V - v[i] * v[i]) / (2 * a[i]);
            if (d[i] + ttt >= L) c[i] = {d[i], L + 1, 0};
            else c[i] = {d[i], d[i] + ttt, 0};
        } 
    }

    int ans = 0; cnt = 0; node pos;
    for (int i = 1; i <= n; i ++ ) {
        if (c[i].tag == -1) continue;
        int t = ask(c[i].l, c[i].tag);
        if (t == -1) continue;
        if (p[t] >= c[i].r) continue;
        ans ++ ; st[i] = 1;
        if (c[i].r != L + 1) b[++ cnt] = c[i];
        else {
            if (pos.l < c[i].l) pos = c[i];
            else if (pos.l == c[i].l && c[i].tag == 0) pos = c[i]; 
        }
    }
    cout << ans << ' ';

    if (ans == 0) cout << m << '\n';
    else cout << m - 1 << '\n';
}

signed main(void) {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    cin >> T;
    while (T -- ) {
        for (int i = 1; i <= n; i ++ ) st[i] = 0;
        cin >> n >> m >> L >> V;
        for (int i = 1; i <= n; i ++ ) cin >> d[i] >> v[i] >> a[i];
        for (int i = 1; i <= m; i ++ ) cin >> p[i];
        if (check_A()) solve_A();
        else if (check_B()) {
            solve_B();
        }
    }
    return 0;
}